package lib.wzh.com.libcore.framework.chain;

import lib.wzh.com.libcore.framework.response.BaseResponse;

/**
 * @Author lib
 * @Date 2021/12/4 13:57
 * @ClassName AReturnChain
 * @Version v1.0
 */

public abstract class ReturnChain {

    private  ReturnChain chain;

    public void setChain(ReturnChain chain) {
        this.chain = chain;
    }

    public ReturnChain getChain() {
        return chain;
    }

    /**返回值结果判断
     * @author lib
     * @date 2021/12/4 14:00
     * @param t 请求参数
     * @return 返回结果
     * @since: jdk1.8
     * @update [序号][日期YYYY-MM-DD] [更改人姓名][变更描述]
     */
    public abstract <T> BaseResponse<T> returnHandler(T t);


    public static class Builder{
        private ReturnChain head;
        private ReturnChain tail;

        public Builder addBuilder(ReturnChain chain){
            if(null == this.head){
                this.head = this.tail = chain;
                return this;
            }
            this.tail.setChain(chain);
            this.tail = chain;
            return this;
        }

        public ReturnChain builder(){
            return this.head;
        }

    }
}
